package com.tqz.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.tqz.dao.NewsSerch_user;

@WebServlet("/UpdateUserServlet")


public class UpdateUserServlet extends HttpServlet {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// 防止中文乱码，设置字符集
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charSet=utf-8");
		String olduserpwd = "";
		String newuserpwd = "";
		olduserpwd = request.getParameter("olduserpwd");
		newuserpwd = request.getParameter("newuserpwd");
		String repath = request.getContextPath();// 获取当前路径上下文
		NewsSerch_user user=new NewsSerch_user();
		if(user.updateUser(olduserpwd, newuserpwd)) {
			response.sendRedirect(repath + "/optionnewssuccess.jsp");
		}else {
			response.sendRedirect(repath + "/choose.jsp?option=4");
			
			System.out.println("error!");
		}
		
	}
}
